package com.example.lncd.api;

import com.example.lncd.model.GeoFence;
import com.example.lncd.model.Location;
import com.example.lncd.model.LocationRequest;
import com.example.lncd.model.User;

import java.util.List;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface ApiService {

    // 用户相关接口
    @POST("users/register")
    Call<User> registerUser(@Body User user);

    @POST("users/login")
    Call<User> loginUser(@Body User user);

    @GET("users/{id}")
    Call<User> getUserById(@Path("id") Long id);

    @GET("users")
    Call<List<User>> getAllUsers();

    @PUT("users/{id}")
    Call<User> updateUser(@Path("id") Long id, @Body User user);

    // 位置相关接口
    @POST("locations")
    Call<Location> addLocation(@Body Location location);

    @POST("locations/simple")
    Call<Location> addSimpleLocation(@Body LocationRequest locationRequest);

    @GET("locations/user/{userId}/latest")
    Call<Location> getLatestLocation(@Path("userId") Long userId);

    @GET("locations/user/{userId}")
    Call<List<Location>> getUserLocations(@Path("userId") Long userId, @Query("startTime") String startTime, @Query("endTime") String endTime);

    // 地理栅栏相关接口
    @POST("geofences")
    Call<GeoFence> createGeoFence(@Body GeoFence geoFence);

    @GET("geofences/creator/{creatorId}")
    Call<List<GeoFence>> getGeoFencesByCreator(@Path("creatorId") Long creatorId);

    @GET("geofences/target/{targetUserId}")
    Call<List<GeoFence>> getGeoFencesByTarget(@Path("targetUserId") Long targetUserId);

    @PUT("geofences/{id}")
    Call<GeoFence> updateGeoFence(@Path("id") Long id, @Body GeoFence geoFence);

    @DELETE("geofences/{id}")
    Call<Void> deleteGeoFence(@Path("id") Long id);

    // 用户关联关系接口
    @POST("users/{userId}/relate/{relatedUserId}")
    Call<User> relateUser(@Path("userId") Long userId, @Path("relatedUserId") Long relatedUserId);

    @DELETE("users/{userId}/unrelate/{relatedUserId}")
    Call<User> unrelateUser(@Path("userId") Long userId, @Path("relatedUserId") Long relatedUserId);

    @GET("users/{userId}/related")
    Call<List<User>> getRelatedUsers(@Path("userId") Long userId);
} 